package com.example.leetdemo.finash;

public class Solution3195 {

    public int minimumArea(int[][] grid) {
        int l = grid[0].length, r = 0, w = grid.length, b = 0;
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[i].length; j++) {
                if (grid[i][j] == 1) {
                    l = Math.min(l, j);
                    r = Math.max(r, j);
                    w = Math.min(w, i);
                    b = Math.max(b, i);
                }
            }
        }
        return (r - l + 1) * (b - w + 1);
    }

}
